#!/bin/bash
set -e

cd $(dirname $0)/..

echo Running validation

PACKAGES="$(go list ./...)"

echo Running: go vet
go vet ${PACKAGES}
echo Running: gometalinter
for i in ${PACKAGES}; do
    if [ -n "$(gometalinter $i | grep -v 'should have comment.*or be unexported' | tee /dev/stderr)" ]; then
        failed=true
    fi
done
test -z "$failed"
echo Running: go fmt
test -z "$(go fmt ${PACKAGES} | tee /dev/stderr)"
